Skip to content

Conversation

@pavel-jares-bcm
Copy link
Contributor

@pavel-jares-bcm pavel-jares-bcm commented Oct 23, 2025

Description

This PR add a test that simulate one known issue about communication to the service. When communication is broken it stop sending a request and an exception is thrown.

The point is that GET request could be retried (GET means no change on remote side), but for POST it depends on the state. If request was sent (at least from application point of view) we cannot retry it, because it could be effective done twice. We can potentially retry other method than GET only if the error happened before sending the data.

This test could be helpfull in case of replacing HTTP client or for reproducing a similar issue. It definetelly cover these edge cases and define current state.

Linked to # (issue)
Part of the # (epic)

Type of change

Please delete options that are not relevant.

  • fix: Bug fix (non-breaking change which fixes an issue)
  • feat: New feature (non-breaking change which adds functionality)
  • docs: Change in a documentation
  • refactor: Refactor the code
  • chore: Chore, repository cleanup, updates the dependencies.
  • BREAKING CHANGE or !: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the style guidelines of this project
  • PR title conforms to commit message guideline ## Commit Message Structure Guideline
  • I have commented my code, particularly in hard-to-understand areas. In JS I did provide JSDoc
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The java tests in the area I was working on leverage @nested annotations
  • Any dependent changes have been merged and published in downstream modules

For more details about how should the code look like read the Contributing guideline

Signed-off-by: Pavel Jareš <Pavel.Jares@broadcom.com>
pavel-jares-bcm and others added 3 commits October 23, 2025 10:04
Signed-off-by: Pavel Jareš <Pavel.Jares@broadcom.com>
…ying POST - reactor.netty.http.client.PrematureCloseException)

Signed-off-by: Pavel Jareš <Pavel.Jares@broadcom.com>
@EvaJavornicka EvaJavornicka moved this from New to In Progress in API Mediation Layer Backlog Management Oct 29, 2025
@pavel-jares-bcm pavel-jares-bcm marked this pull request as ready for review November 14, 2025 13:32
Comment on lines +147 to +168
void givenConnectionInPool_whenServerWasRestarted_thenRetry(String method, MockService.ConnectionCleanupType cleanupType, int responseStatus) {
var port = mockService.getPort();

given()
.header(HEADER_X_FORWARD_TO, "serviceid1")
.when()
.get(basePath + "/200")
.then()
.statusCode(is(SC_OK));

mockService.cleanConnections(cleanupType);

var port2 = mockService.getPort();
assertEquals(port, port2);

given()
.header(HEADER_X_FORWARD_TO, "serviceid1")
.when()
.request(method, basePath + "/200")
.then()
.statusCode(is(responseStatus));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what the purpose of this test is, what happens if you try to send the request before cleaning up? Would that make the purpose more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The first request is to warn up. It means the pool on both services side is established. The clean-up close connection on one side (the type simulate a specific operation) and the second call verify the handling of closed connection. We can make as many request we want before. It cannot change the behaviour after clean up. And the issue is related to the first call after clean-up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering what does it take to break this test, that's the part that's not very clear for me. Or which part of the API ML does not work otherwise, it feels to me that it's testing the mock service rather, but if it's clear to you it's fine with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is testing the retry logic and handling connection in the outbound calls (see HTTP client in the gateway), If there is a change in handling I/O exceptions of prepared connection or retry logic it could break the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants